package com.hoyue.service;

import com.hoyue.bean.Department;
import com.hoyue.dao.DepartmentDao;
import com.hoyue.dao.impl.DepartmentDaoImpl;

import java.sql.SQLException;
import java.util.List;

public class DepartmentService {
    DepartmentDao departmentDao = new DepartmentDaoImpl();

    public void addDepartment(Department department) {
        try {
            departmentDao.addDepartment(department);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void deleteDepartment(int id) {
        try {
            departmentDao.deleteDepartment(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void updateDepartment(Department department) {
        try {
            departmentDao.updateDepartment(department);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public List<Department> getAllList() {
        try {
            return departmentDao.getAllList();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getAddressById(int id) {
        try {
            return departmentDao.getAddressById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

}
